import request from "@/service";

// 商品接口
enum EmployeeAPI {
  add = "/commodity/saveCommodity",
  updata = "/commodity/updateCommodity",
  detele = "/commodity/deleteCommodity",
  getData = "/commodity/limitCommodity",
  updataStatus = "/commodity/selectStatus",
  addCategory1 = "/ProductAtegory/save", //添加一级分类
  updataCategory1 = "/ProductAtegory/update",
  deleteCategory1 = "/ProductAtegory/delete",
  getCategory1 = "/ProductAtegory/select"
  // addCategory2 = ""
}
// 添加
export const addGoods = (data: any) =>
  request.post<any>({ url: EmployeeAPI.add, data });

// 修改
export const updataGoods = (data: any) => {
  request.post<any>({ url: EmployeeAPI.updata, data });
};
// 删除
export const deleteGoods = (id: any) =>
  request.delete<any>({ url: EmployeeAPI.detele, params: { id } });

// 获取
export const getGoods = ({ start, end }: any) =>
  request.get<any>({ url: `${EmployeeAPI.getData}?start=${start}&end=${end}` });

// 修改状态
export const updataStatus = ({ id, status }: any) =>
  request.get<any>({
    url: EmployeeAPI.updataStatus + `?id=${id}&sku_status=${status}`
  });

//添加一级分类
export const addCategory = (data: any) => {
  return request.post<any>({ url: EmployeeAPI.addCategory1, data });
};

// 删除分类
export const deleteCategory = (data: any) => {
  return request.delete<any>({
    url: EmployeeAPI.deleteCategory1,
    data
  });
};
//修改分类
export const updataCategory = (data: any) => {
  return request.put<any>({
    url: EmployeeAPI.updataCategory1,
    data
  });
};

// 获取分类
export const getCategory = () => {
  return request.get<any>({ url: EmployeeAPI.getCategory1 });
};
